public class Test18 {
    public static void main(String[] args) {
        Car[] cars = new Car[]{new PassageCar(1, "AudiA4", 5),
                new PassageCar(2, "wuling", 7)};

        int peopleNum = 0;

        for (int i = 0; i < cars.length; i++) {
            if (cars[i] instanceof PassageCar) {
                PassageCar p = (PassageCar)cars[i];
                peopleNum += p.getHumanNum();
            }
        }

        System.out.println(peopleNum);
    }
}

abstract class Car {
    int carId;
    String carName;

    public Car(int carId, String Name) {
        this.carId = carId;
        this.carName = carName;
    }

    public abstract String getCapacity();
}

interface HumanNum {
    public abstract int getHumanNum();

    public abstract void setHumanNum(int humanNum);
}

class PassageCar extends Car implements HumanNum {
    private int humanNum;

    public PassageCar(int carId, String carName, int humanNum) {
        super(carId, carName);
        this.humanNum = humanNum;
    }

    @Override
    public int getHumanNum() {
        return humanNum;
    }

    @Override
    public String getCapacity() {
        return "载人数" + this.getHumanNum() + "人";
    }

    @Override
    public void setHumanNum(int humanNum) {
        this.humanNum = humanNum;
    }
}